<template>
  <View>
    <canvas canvas-id="qrcodeCanvas"></canvas>
  </View>
</template>


<script>
export default {
  name: 'Index',
  data() {
    return {

    }
  },
  onReady() {
    const ctx = wx.createCanvasContext('qrcodeCanvas'); // 创建canvas绘图上下文

    const path = "pages/index/index"; // 要跳转的页面路径

    wx.qrcode.create({
      path: path, // 设置二维码跳转路径
      width: qrcodeWidth,
      height: qrcodeHeight,
      success(res) {
        ctx.drawImage(res.path, 0, 0, qrcodeWidth, qrcodeHeight); // 绘制二维码
        ctx.draw();
      },
      fail(err) {
        console.error(err);
      }
    });
  }
}

</script>